*Replication for: TEELE (2023) The Political Geography of the Gender Gap.
*Generates figure 2


********************************************************
*	1. Calculate fact cited in text
*	2. Generate Figure 2a
*  	3. Generate Figure 2b 
*	4. Generate Figure 2c
*	5. Generate Figure 2d
********************************************************

		
**************************************************************************
*1: Fact cited in text
****************************************************************************

use "Sweden 1911-1944_panel.dta", clear


		collapse (sum) Valid VT VTmen VTwomen ID city town  Elect Electmen Electwomen, by(CityTown year)

		gen VTw_urban = (VTwomen/Electwomen)*100 if CityTown==1
		gen VTw_rural = (VTwomen/Electwomen)*100 if CityTown==0

		gen VTm_rural = (VTmen/Electmen)*100 if CityTown==0
		gen VTm_urban = (VTmen/Electmen)*100 if CityTown==1

	 
		label define urban 0 "Rural" 1 "Urban"
		label values CityTown urban

		*Fact: 
		gen shareeligible=Electwomen/(Electmen+Electwomen)
		list shareeligible City if year==1921 /*fact cited in paper women 50.8% eligible in rural, 55.7 in Urban including Stockholm*/ 
	
		list City VTwomen VTw_urban VTw_rural VTmen VTm_rural VTm_urban if year==1921
	
		/*In 1921, 
		men cast 659508 votes rural
		women cast 501005 votes rural
		men cast 288541 votes urban
		women cast 	295414 votes urban*/



********************************************************************
*Figure 2a: Eligible Electorate and urban rural 1911-1944
********************************************************************

	sort CityTown 
	
	# delimit ;
	twoway 
		(connected Electmen year if CityTown==1, lcolor(blue) msym(none) lwidth(vthick)) 
		(connected Electmen year if CityTown==0, lcolor(navy) msym(none) lwidth(vthick))
		(connected Electwomen year if CityTown==1 & year>=1921, lcolor(purple) lwidth(vthick) msym(none))  
		(connected Electwomen year if CityTown==0 & year>=1921, lcolor(pink) msym(none) lwidth(vthick)), 
		
		ytitle("Eligible Electorate", size(large)) ysca(titlegap(*10))
		xtitle("Election Year", size(large)) xsca(titlegap(*10)) 
		ylabel(, format(%15.0fc))
		xlab(1911 1913.8 " "  1914.2 "1914" 1917 1920 " " 1921 1924 1928 1932 1936 1940 1944)
		xline(1921, lwidth(5) lc(gs12)) 	
			text(900000 1914 "Rural Men", color(navy)) 
			text(300000 1914  "Urban Men", color(blue)) 
			text(1150000 1940 "Rural Women", color(pink)) 
			text(850000 1932 "Urban Women", color(purple)) 
	
		legend(ring(0) pos(4))   legend(off)  
		scheme(tufte) name(geligible, replace) 
		;
	# delimit cr

	graph export "./images/Fig2a.eps", replace

*************************************************************************************
*Figure 2b: Turnout by gender and urban rural districts 1911-1944
*************************************************************************************

	# delimit ;
	twoway 
		(connected VTm_urban year, lcolor(blue) msym(none) lwidth(vthick) ) 
		(connected VTm_rural year , lcolor(navy) msym(none) lwidth(vthick))
		(connected VTw_urban year if year>=1921, lcolor(purple) msym(none) lwidth(vthick))  
		(connected VTw_rural year if year>=1921, lcolor(pink) msym(none) lwidth(vthick)), 
		
		ytitle("Turnout (%)", size(large)) 
		xtitle("Election Year", size(large))
		xlab(1911 1913.8 " "  1914.2 "1914" 1917 1920 " " 1921 1924 1928 1932 1936 1940 1944) ysca(titlegap(*10)) xsca(titlegap(*10)) 
		
		text(56 1914 "Rural Men", color(navy)) 
		text(79 1914  "Urban Men", color(blue)) 
		text(62 1940 "Rural Women", color(pink)) 
		text(70 1940 "Urban Women", color(purple)) 
		 legend(off) xline(1921, lwidth(5) lc(gs12)) scheme(tufte) name(gturnout, replace)
		;
	 
	# delimit cr 
	graph export "./images/Fig2b.eps", replace


*************************************************************************************
*Paper Figure 2c: Women's Share of the vote in urban versus rual constituencies 
*************************************************************************************

	gen WS_urban = (VTwomen/VT)*100 if CityTown==1
	gen WS_rural = (VTwomen/VT)*100 if CityTown==0

	keep if year>=1921

	# delimit ;
	twoway 
		(connected WS_urban year, lcolor(purple) msym(none) lwidth(vthick))  
		(connected WS_rural year, lcolor(pink) msym(none) lwidth(vthick))
	,     
		ytitle("Women's Share of Turnout (%)", size(large))  ysca(titlegap(*10)) 
		xtitle("Election Year", size(large) )  xsca(titlegap(*10))
		xlab(1911 1913.8 " "  1914.2 "1914" 1917 1920 " " 1921 1924 1928 1932 1936 1940 1944) 
		xline(1921, lwidth(5) lc(gs12)) scheme(tufte) legend(off) 
	
		text(52 1940 "Share Urban Turnout", color(purple)) 
		text(47 1940 "Share Rural Turnout", color(pink)) 
	;
	
	# delimit cr
	graph export "./images/Fig2c.eps", replace

*****************************************************************************
*Paper Figure 2d: Turnout Gap across all elections 
******************************************************************************

	use "Sweden 1911-1944_panel.dta", clear

	keep if year >=1921

	
	gen TD=TE_m-TE_w /*Tunout difference*/ 

	sort year TD

	bys year: count if TD<0	/*fact cited in paper */ 
	bys year: sum Elect  /*fact cited in paper */ 
	bys year: sum Elect if TD<0 /*fact cited in paper */ 

	forvalues n = 4(4)12 {
	local xlab `xlab' `n' "`=string(round(exp(`n'),10),"%9.0fc")'"
}
	
	
	# delimit ; 
	twoway 
		(scatter TD lnElect if TD>=0 , mcolor(gs12) yline(0) lcolor(blue) msize(tiny) msym(.)) 
		(scatter TD lnElect if TD<0, mcolor(red))  , 
		by(year, note("")  )  
		xtitle("Log Electorate Size", size(large)) 
		xsca(titlegap(*10)) 
		xlab(`xlab')
		ytitle("Men's Turnout - Women's Turnout", size(large))
		legend( label(2 "Women's Turnout > Men's Turnout") order(2) ) 
		 scheme(tufte)
		 
		;
		
		# delimit cr 
		gr_edit legend.xoffset = 35
		gr_edit legend.yoffset = 20
		
		graph export  "./images/Fig2d.eps", replace 

	*Note to readers: there is an observation in 1921 where the sole observation where the difference is <-30 is Visnums kil 1944. This has been double checked with original data and is correct. 
	
	bys year: count if TD<0	& year==1921 
	bys year: sum Elect if TD<0 & year==1921
	
	
	*Note to readers: In 1921 there are 13 parishes where women's turnout was higher than men. the average parish electorate size was 1233 overall. In the 13 parishes where men turned out at lower rates than men it was 411. In other words these are really small, rural places. It is a difference of 17 votes on average. the average percentage point difference in men's and womens' turnout is 4.6, the largest was 18 points. 
	








	

